const path = require('path');
const webpack = require('webpack');
const htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
    entry: path.resolve(__dirname,'./src/main.js'),
    output: {
        path: path.resolve(__dirname,'./dist'),
        filename: 'bundle.js'
    },
    devServer: {
        host: '127.0.0.1',
        open: true,
        port: 3000,
        contentBase: './src',
        hot: true
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new htmlWebpackPlugin({
            template: path.resolve(__dirname,'./src/index.html'),//模板路径
            filename: 'index.html' //生成的html，自动就在根目录下
        })
    ],
    module: {
        rules: [
            {test: /\.css$/, use: ['style-loader','css-loader']},
            {test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader']},
            {test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader']},
            {test: /\.(gif|jpg|jpeg|png|woff|woff2|svg|eot|ttf)$/i, loader: 'url-loader?limit=62400'},
            // {test: /\.js$/, use: 'babel-loader', exclude: /nodel_modules/}
            { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ },
            {test: /\.vue$/, use: 'vue-loader'}
        ]
    }
}